package com.flatshare.project;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;

public class LogIn extends Activity implements View.OnClickListener{
	
	TextView tvUsername;
	EditText etUsername;
	TextView tvPassword;
	EditText etPassword;
	Button bSubmit;
	ToggleButton tbConceal;
	Button bForgot;
	
	protected void onCreate(Bundle LogInScreen) {
		
		super.onCreate(LogInScreen);
		setContentView(R.layout.login);
		
		setVariables();
		setOnClickListeners();

	}

	private void setOnClickListeners() {
		// TODO Auto-generated method stub
		bSubmit.setOnClickListener(this);
		tbConceal.setOnClickListener(this);
		bForgot.setOnClickListener(this);
	}

	private void setVariables() {
		
		tvUsername = (TextView) findViewById(R.id.tvUsername);
		etUsername = (EditText) findViewById(R.id.etUsername);
		tvPassword = (TextView) findViewById(R.id.tvPassword);
		etPassword = (EditText) findViewById(R.id.etPassword);
		bSubmit = (Button) findViewById(R.id.bSubmit);
		tbConceal = (ToggleButton) findViewById(R.id.tbConceal);
		bForgot = (Button) findViewById(R.id.bForgot);
	}

	public void onClick(View v) {
		
		switch (v.getId()) {
		case R.id.bSubmit:
	
			sendUserPass();
			finish();
			break;	
		case R.id.tbConceal:
			
			if (tbConceal.isChecked()){
				etPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
			}else{
				etPassword.setInputType(InputType.TYPE_CLASS_TEXT);
			}
			break;
		case R.id.bForgot:
			Intent openAdd = new Intent("com.test.clinton.FORGOT");
			startActivity(openAdd);
			break;
			}
		}
		
	private void sendUserPass() {
		
		//////////////////////////////////////Send Username and Password to Web Server
	}

	@Override
	protected void onPause() {
		
		super.onPause();
		finish();
	}
}